package team.seekers.oj.homework.enums;


import com.baomidou.mybatisplus.annotation.IEnum;
import lombok.Getter;

import java.util.Arrays;

@Getter
public enum HomeworkStatusEnum implements IEnum<Integer> {
    WAIT(0, "未开始"),
    OPEN(1,  "进行中"),
//    CHECKING(2, "已提交待批阅"),
    END(2, "已结束");

    private int type;

    private String name;

    HomeworkStatusEnum(int type, String name) {
        this.type = type;
        this.name = name;
    }

    @Override
    public Integer getValue() {
        return this.type;
    }

    public static HomeworkStatusEnum getByType(int type) {
        return Arrays.stream(values()).filter(e -> e.getType() == type).findFirst().orElse(null);
    }

    public static HomeworkStatusEnum getByName(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
    }
}

